<html xmlns="http://www.w3.org/1999/xhtml">
<head>
  <meta charset="utf-8">
  <title><!--{$lang.page.index.title}--></title>
  <meta name="renderer" content="webkit">
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
  <link rel="stylesheet" href="/static/lay/layui/css/layui.css" media="all">
  <link rel="stylesheet" href="/static/lay/layui/index.css" media="all">
</head>
<body>

  <div class="layui-fluid">

    <div class="layui-card">

      <div class="layui-card-body" style="padding: 15px;">
        <form name="addItem" method="post" lay-filter="component-form-group" class="layui-form">
          <input type="hidden" value="<!--{$datainfo.id}-->" name="id">
          <input type="hidden" value="<!--{$datainfo.cname}-->" name="cname">
            <div class="layui-form-item">

              <div class="layui-inline">
                <label class="layui-form-label"><!--{$lang.page.table.name}--></label>
                <div class="layui-input-inline">
                 <input type="text" name="title" lay-verify="required" value="<!--{$datainfo.title}-->" placeholder="<!--{$lang.page.public.pinput}-->" autocomplete="off" class="layui-input"/>
                </div>
              </div>

              <div class="layui-inline">
                  <label class="layui-form-label"><!--{$lang.page.table.toclass}--></label>
                  <div class="layui-input-block">
                      <select name="cid" lay-filter="brickType">
                         <option value="0"><!--{$lang.page.table.higtestype}--></option>
                         <!--{foreach from=$class item=item}-->
                         <option data-cname="<!--{$item.title}-->"  value="<!--{$item.id}-->" <!--{if $datainfo.cid eq $item.id}-->selected<!--{/if}-->><!--{$item.strsign}--><!--{$item.title}--></option>
                         <!--{/foreach}-->
                      </select>
                  </div>
              </div>

              <div class="layui-inline">
              <label class="layui-form-label"><!--{$lang.page.table.code}--></label>
              <div class="layui-input-inline" >
                  <input type="text" name="procode" lay-verify="required" value="<!--{$datainfo.procode}-->" placeholder="<!--{$lang.page.public.pinput}-->" autocomplete="off" class="layui-input"/>
              </div>
              </div>

              <div class="layui-inline">
              <label class="layui-form-label"><!--{$lang.page.table.everym}--> <!--{$lang.page.table.fee}--></label>
              <div class="layui-input-inline" >
                 <input type="text" name="fee" value="<!--{$datainfo.fee}-->" placeholder="<!--{$lang.page.public.pinput}-->" autocomplete="off" class="layui-input" />
              </div>
            </div>

            </div>

            <div class="layui-form-item">

            

            <div class="layui-inline">
              <label class="layui-form-label"><!--{$lang.page.table.everyp}--> <!--{$lang.page.table.price}--></label>
              <div class="layui-input-inline" >
                  <input type="text" name="price" value="<!--{$datainfo.price}-->" placeholder="<!--{$lang.page.public.pinput}-->" autocomplete="off" class="layui-input" />
              </div>
            </div>

            <div class="layui-inline">
              <label class="layui-form-label"><!--{$lang.page.table.everym}--> <!--{$lang.page.table.bond}--></label>
              <div class="layui-input-inline" >
                  <input type="text" name="bond" value="<!--{$datainfo.bond}-->" placeholder="<!--{$lang.page.public.pinput}-->" autocomplete="off" class="layui-input" />
              </div>
            </div>

            <div class="layui-inline">
                <label class="layui-form-label"><!--{$lang.page.public.max}--> <!--{$lang.page.table.holding}--></label>
                <div class="layui-input-inline">
                 <input type="text" name="maxnum" value="<!--{$datainfo.maxnum}-->" placeholder="<!--{$lang.page.public.pinput}-->" autocomplete="off" class="layui-input" />
                </div>
            </div>

            <div class="layui-inline">
              <label class="layui-form-label"><!--{$lang.page.public.min}--> <!--{$lang.page.table.holding}--></label>
              <div class="layui-input-inline" >
                 <input type="text" name="minnum" value="<!--{$datainfo.minnum}-->" placeholder="<!--{$lang.page.public.pinput}-->" autocomplete="off" class="layui-input" />
              </div>
            </div>
          </div>

          <div class="layui-form-item">
              <label class="layui-form-label"><!--{$lang.page.public.fluctuate}--></label>
              <div class="layui-inline" style="width:80%;">
                 <table class="layui-table" lay-filter="table">
                <thead>
                    <tr>
                        <td width="25%"><!--{$lang.page.public.maxbeat}--> <!--{$lang.page.public.multiple}--></td>
                        <td width="25%"><!--{$lang.page.public.minbeat}--> <!--{$lang.page.public.multiple}--></td>
                        <td width="25%"><!--{$lang.page.public.minbeat}--> <!--{$lang.page.public.value}--></td>
                        <td width="25%"><!--{$lang.page.public.numsize}--></td>
                    </tr>
                </thead>
                <tbody>
                     <tr>
                     <td><input type="text" name="beatpoint[top]" lay-verify="top" value="<!--{$datainfo.beatpoint.top}-->" placeholder="<!--{$lang.page.public.pinput}-->" autocomplete="off" class="layui-input" /></td>
                     <td><input type="text" name="beatpoint[low]" lay-verify="low" value="<!--{$datainfo.beatpoint.low}-->" placeholder="<!--{$lang.page.public.pinput}-->" autocomplete="off" class="layui-input" /></td>
                     <td><input type="text" name="beatpoint[rands]" lay-verify="rands" value="<!--{$datainfo.beatpoint.rands}-->" placeholder="<!--{$lang.page.public.pinput}-->" autocomplete="off" class="layui-input" /></td>
                     <td><input type="text" name="beatpoint[length]" lay-verify="length" value="<!--{$datainfo.beatpoint.length}-->" placeholder="<!--{$lang.page.public.pinput}-->" autocomplete="off" class="layui-input" /></td>
                     </tr>
                  </tbody>
                </table>
              </div>
            </div>

            <!--开市方式-->
            <div class="layui-form-item">
              <div class="layui-inline">
                 <label class="layui-form-label"><!--{$lang.page.table.openmark}--> <!--{$lang.page.table.method}--></label>
                  <div class="layui-input-block">
                    <input type="radio" name="opentype" value="1" title="自动" lay-filter="opentype" <!--{if $datainfo.opentype eq 1}--> checked<!--{/if}-->>&nbsp;&nbsp;<input type="radio" name="opentype" value="2" title="手动" lay-filter="opentype" <!--{if $datainfo.opentype eq 2}--> checked<!--{/if}--> >
                  </div>
              </div>
            </div>

            <div class="layui-form-item" id="opentime" <!--{if $datainfo.opentype neq 2}-->style="display: none;"<!--{/if}-->>
                <label class="layui-form-label"><!--{$lang.page.public.opentime}--></label>
                <div class="layui-inline" style="width:80%;">
                <table class="layui-table" >
                  <thead>
                    <tr>
                        <td width="10%"><!--{$lang.page.table.time}--></td>
                        <td width="90%"><!--{$lang.page.table.set}--></td>
                    </tr>
                  </thead>
                  <tbody>
                   <!--{foreach name=opentime from=$datainfo.opentime item=item key=key}-->
                     <tr>
                     <td>周<!--{$key}--></td>
                     <td><input type="text" name="opentime[]" value="<!--{$item}-->" placeholder="<!--{$lang.page.public.informat}--> 00:00~03:00|08:00~24:00" autocomplete="off" class="layui-input" /></td>
                     </tr>
                     <!--{/foreach}-->
                  </tbody>
                </table>
              </div>  
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label"><!--{$lang.page.table.closeing}--> <!--{$lang.page.table.time}--></label>
                <div class="layui-inline" style="width:80%; display: flex; justify-content: space-between;">
                  <!--{foreach name=selltime from=$datainfo.selltime item=item key=key}-->
                     <div>
                     <div>周<!--{$key}--></div>
                     <div><input type="text" name="selltime[]" value="<!--{$item}-->" placeholder="<!--{$lang.page.public.informat}--> 00:00" autocomplete="off" class="layui-input" style="width:80%;"/></div>
                     </div>
                     <!--{/foreach}-->
                </div>  
            </div>

            <div class="layui-form-item showfk">
              <label class="layui-form-label"><!--{$lang.page.public.langinfo}--></label>
              <div class="layui-inline" id="submue"  style="width:80%;">
                <table class="layui-table" id="sharetable" lay-filter="table">
                <thead>
                    <tr>
                        <td width='25%'><!--{$lang.page.public.lang}--></td>
                        <td width='55%'><!--{$lang.page.public.title}--></td>
                        <td width='20%'><a class="layui-btn layui-btn-xs addshare"><!--{$lang.page.public.add}--></a></td>
                    </tr>
                </thead>
                <tbody>
                    <!--{if empty($datainfo.langinfo)}-->
                    <tr>
                      <td>
                        <select name="langs[]">
                          <option value=""><!--{$lang.page.public.select}--></option>
                          <!--{foreach from=$langs.list item=item}-->
                          <option value="<!--{$item.value}-->"><!--{$item.name}--></option>
                          <!--{/foreach}-->
                        </select>
                      </td>
                      <td><input type="text" name="titles[]" value="" class="layui-input"></td>
                      <td><a class="layui-btn layui-btn-danger layui-btn-xs delshare"><!--{$lang.page.public.del}--></a></td>
                    </tr>
                     <!--{else}-->
                     <!--{foreach from=$datainfo.langinfo item=item key=key}-->
                    <tr>
                      <td>
                        <select name="langs[]">
                          <option value=""><!--{$lang.page.public.select}--></option>
                          <!--{foreach from=$langs.list item=items}-->
                          <option value="<!--{$items.value}-->" <!--{if $key eq $items.value}-->selected<!--{/if}-->><!--{$items.name}--></option>
                          <!--{/foreach}-->
                        </select>
                      </td>
                      <td><input type="text" name="titles[]" value="<!--{$item.titles}-->" class="layui-input"></td>
                      <td><a class="layui-btn layui-btn-danger layui-btn-xs delshare"><!--{$lang.page.public.del}--></a></td>
                    </tr>
                     <!--{/foreach}-->
                     <!--{/if}-->
                  </tbody>
                </table>
              </div>

            </div>

            <div class="layui-form-item">

              <div class="layui-inline">
              <label class="layui-form-label"><!--{$lang.page.table.keeping}--></label>
              <div  class="layui-input-inline" >
                   <input type="radio" lay-filter="retention" name="retention" value="1" title="<!--{$lang.page.table.yes}-->"  <!--{if $datainfo.retention eq 1}--> checked<!--{/if}--> />&nbsp;&nbsp;<input type="radio" lay-filter="retention" name="retention" value="2" title="<!--{$lang.page.table.no}-->" <!--{if $datainfo.retention eq 2}--> checked<!--{/if}--> />
              </div>
              </div>

              <div class="layui-inline retention" <!--{if $datainfo.retention neq 1}-->style="display: none;"<!--{/if}-->>
              <label class="layui-form-label"><!--{$lang.page.table.keeping}--> <!--{$lang.page.table.everym}--> <!--{$lang.page.table.fee}--> </label>
              <div class="layui-input-inline" >
                  <input type="text" name="retfee[fee]" value="<!--{$datainfo.retfee.fee}-->" placeholder="<!--{$lang.page.public.pinput}-->" autocomplete="off" class="layui-input" />
              </div>
              </div>

              <div class="layui-inline retention" <!--{if $datainfo.retention neq 1}-->style="display: none;"<!--{/if}-->>
              <label class="layui-form-label"><!--{$lang.page.public.max}--> <!--{$lang.page.table.keeping}--> <!--{$lang.page.table.time}--></label>
              <div class="layui-input-inline" >
                  <input type="text" name="retfee[timelong]" value="<!--{$datainfo.retfee.timelong}-->" placeholder="<!--{$lang.page.public.pinput}-->" autocomplete="off" class="layui-input" />
              </div>
              </div>

            </div>

            <div class="layui-form-item">

              <div class="layui-inline">
              <label class="layui-form-label"><!--{$lang.page.table.changing}--></label>
              <div  class="layui-input-inline" >
                   <input type="radio" lay-filter="ischange" name="ischange" value="1" title="<!--{$lang.page.table.yes}-->"  <!--{if $datainfo.ischange eq 1}--> checked<!--{/if}--> />&nbsp;&nbsp;<input type="radio" lay-filter="ischange" name="ischange" value="2" title="<!--{$lang.page.table.no}-->" <!--{if $datainfo.ischange eq 2}--> checked<!--{/if}--> />
              </div>
              </div>

              <div class="layui-inline ischange" <!--{if $datainfo.ischange neq 1}-->style="display: none;"<!--{/if}-->>
              <label class="layui-form-label"><!--{$lang.page.public.curtail}--></label>
              <div class="layui-input-inline" >
                  <input type="text" id="nobuy" name="exchange[nobuytime]" value="<!--{$datainfo.exchange.nobuytime}-->" placeholder="yyyy-MM-dd" autocomplete="off" class="layui-input" />
              </div>
              </div>

              <div class="layui-inline ischange" <!--{if $datainfo.ischange neq 1}-->style="display: none;"<!--{/if}-->>
              <label class="layui-form-label"><!--{$lang.page.public.changing}--> <!--{$lang.page.table.time}--></label>
              <div class="layui-input-inline" >
                  <input type="text" id="change" name="exchange[changetime]" value="<!--{$datainfo.exchange.changetime}-->" placeholder="yyyy-MM-dd" autocomplete="off" class="layui-input" />
              </div>
              </div>

              <div class="layui-inline ischange" <!--{if $datainfo.ischange neq 1}-->style="display: none;"<!--{/if}-->>
              <label class="layui-form-label"><!--{$lang.page.public.opentime}--></label>
              <div class="layui-input-inline" >
                  <input type="text" id="start" name="exchange[starttime]" value="<!--{$datainfo.exchange.starttime}-->" placeholder="yyyy-MM-dd" autocomplete="off" class="layui-input" />
              </div>
              </div>

            </div>

            <div class="layui-form-item">

              <div class="layui-inline">
                <label class="layui-form-label"><!--{$lang.page.table.win}--> <!--{$lang.page.public.fusing}--> <!--{$lang.page.public.multiple}--></label>
                <div class="layui-input-inline">
                 <input type="text" name="fusing[up]" value="<!--{$datainfo.fusing.up}-->" placeholder="<!--{$lang.page.public.pinput}-->" autocomplete="off" class="layui-input" />
                </div>
              </div>

              <div class="layui-inline">
              <label class="layui-form-label"><!--{$lang.page.table.loss}--> <!--{$lang.page.public.fusing}--> <!--{$lang.page.public.multiple}--></label>
              <div class="layui-input-inline" >
                 <input type="text" name="fusing[down]" value="<!--{$datainfo.fusing.down}-->" placeholder="<!--{$lang.page.public.pinput}-->" autocomplete="off" class="layui-input" />
              </div>
              </div>

              <div class="layui-inline">
              <label class="layui-form-label"><!--{$lang.page.public.warnline}--></label>
              <div class="layui-input-inline" >
                 <input type="text" name="ratio[warn]" value="<!--{$datainfo.ratio.warn}-->" placeholder="<!--{$lang.page.public.pinput}-->" autocomplete="off" class="layui-input" />
              </div>
              </div>

              <div class="layui-inline">
              <label class="layui-form-label"><!--{$lang.page.public.closeline}--></label>
              <div class="layui-input-inline" >
                 <input type="text" name="ratio[ratio]" value="<!--{$datainfo.ratio.ratio}-->" placeholder="<!--{$lang.page.public.pinput}-->" autocomplete="off" class="layui-input" />
              </div>
              </div>

            </div>

          <!--end-->
          <div class="layui-form-item">

              <div class="layui-inline">
                <label class="layui-form-label"><!--{$lang.page.table.sort}--></label>
                <div class="layui-input-inline">
                 <input type="text" name="orderid" lay-verify="required" value="<!--{$datainfo.orderid}-->" placeholder="<!--{$lang.page.public.pinput}-->" autocomplete="off" class="layui-input" />
                </div>
              </div>

            </div>

          <div class="layui-form-item">
              <div class="layui-inline">
                 <label class="layui-form-label"><!--{$lang.page.table.status}--></label>
                  <div class="layui-input-block">
                    <input type="radio" name="status" value="1" title="<!--{$lang.page.table.openmark}-->"  <!--{if $datainfo.status eq 1}--> checked<!--{/if}-->>&nbsp;&nbsp;<input type="radio" name="status" value="2" title="<!--{$lang.page.table.closemark}-->" <!--{if $datainfo.status eq 2}--> checked<!--{/if}--> >&nbsp;&nbsp;<input type="radio" name="status" value="3" title="<!--{$lang.page.table.close}-->" <!--{if $datainfo.status eq 3}--> checked<!--{/if}--> >
                  </div>
              </div>
              <div class="layui-inline">
                 <label class="layui-form-label"><!--{$lang.page.table.order}--> <!--{$lang.page.index.number}--></label>
                  <div class="layui-input-block">
                    <input type="radio" name="orders" value="1" title="<!--{$lang.page.public.oneorder}-->"  <!--{if $datainfo.orders eq 1}--> checked<!--{/if}-->>&nbsp;&nbsp;<input type="radio" name="orders" value="2" title="<!--{$lang.page.public.moreorder}-->" <!--{if $datainfo.orders eq 2}--> checked<!--{/if}--> >
                  </div>
              </div>
          </div>

       
          <div class="layui-form-item layui-layout-admin" >
            <div>
              <div class="layui-footer" style="left: 0;">
                <button class="layui-btn" type="button" id="submit" lay-submit lay-filter="submit"><!--{$lang.page.public.submit}--></button>
                <button type="reset" class="layui-btn layui-btn-primary"><!--{$lang.page.public.reset}--></button>
                <button type="button" class="layui-btn layui-btn-primary" onClick="xadmin.close();" ><!--{$lang.page.table.back}--></button>
              </div>
            </div>
          </div>
        </form>
      </div>
    </div>
  </div>

</body>
</html>

  <script src="/static/lay/layui/layui.js"></script>
  <script type="text/javascript">
    layui.config({
     base: '/static/lay/' //静态资源所在路径
   }).extend({
     xadmin: 'lib/xadmin' //弹窗
   }).use(['jquery', 'layer', 'xadmin','form','laydate'], function(){
    var $ = layui.$;
    var form = layui.form;
    var laydate = layui.laydate;
    var upload = layui.upload;
     form.render(null, 'component-form-group');

    /* 自定义验证规则 */
    form.verify({
      low: function(value){
          if(!(/^[0-9]*$/).test(value)){
            return '<!--{$lang.page.public.paraerror}-->';
          }
      }
     ,top: function(value){
          if(!(/^[0-9]*$/).test(value)){
            return '<!--{$lang.page.public.paraerror}-->';
          }
      }
      ,rands: function(value){
          if(!(/^\d+(\.\d+)?$/).test(value)){
            return '<!--{$lang.page.public.paraerror}-->';
          }
      }
      ,length: function(value){
          if(!(/^[0-9]*$/).test(value)){
            return '<!--{$lang.page.public.paraerror}-->';
          }
      }  
    });

    //动态添加表单
    //因为动态添加的元素class属性是无效的，所以不能用
    $('body').on('click', '.addshare', function() {
      if ($('#sharetable tbody tr').length > <!--{$langs.total-1}-->) {
        layer.msg('<!--{$lang.page.public.moreset}--> <!--{$langs.total}--> <!--{$lang.page.public.strip}-->', {
            offset: '20px', 
            time : 2000
        });
      }else{
      //添加html
        var html = '<tr>'+
          '<td><select name="langs[]"><option value=""><!--{$lang.page.public.select}--></option>'+
          <!--{foreach from=$langs.list item=item}-->
          '<option value="<!--{$item.value}-->"><!--{$item.name}--></option>'+
          <!--{/foreach}-->
          '</select></td>'+
          '<td><input type="text" name="titles[]" value="" class="layui-input"></td>'+
          '<td>'+'<a class="layui-btn layui-btn-danger layui-btn-xs delshare"><!--{$lang.page.public.del}--></a>'+
          '</td>'+
          '</tr>';
        //添加到表格最后
        $(html).appendTo($('#sharetable tbody:last'));
        form.render();
      }
    });
    $('body').on('click', '.delshare', function() {
      if ($('#sharetable tbody tr').length === 1) {
        layer.msg('<!--{$lang.page.public.onenodel}-->', {
            time : 2000
        });
      } else {
        //删除当前按钮所在的tr
        $(this).closest('tr').remove();
      }
    });
    
    form.on('select(brickType)', function(data) {
          var cname = $(data.elem).find("option:selected").attr("data-cname");
          $('input[name="cname"]').val(cname);
    });
    
    form.on('radio(opentype)', function(data){
        var opentype = data.value; 
        if(opentype == 1){
            $("#opentime").hide();
        } else if(opentype == 2){
            $("#opentime").show();
        }        
    });

    form.on('radio(retention)', function(data){
        var opentype = data.value; 
        if(opentype == 1){
            $(".retention").show();
        } else if(opentype == 2){
            $(".retention").hide();
        }        
    });

    form.on('radio(ischange)', function(data){
        var opentype = data.value; 
        if(opentype == 1){
            $(".ischange").show();
        } else if(opentype == 2){
            $(".ischange").hide();
        }        
    });

    layui.laydate.render({
        elem: '#nobuy'
    });
    layui.laydate.render({
        elem: '#change'
    });
    layui.laydate.render({
        elem: '#start'
    });
     
    form.on('submit(submit)', function (data) {
          $('#submit').attr("disabled",true);
          $('#submit').addClass('layui-btn-disabled');
          $.post('#',data.field,function(res){
              if(res.code == 200){
                  layer.msg(res.msg);
                  setTimeout(() => {
                     window.parent.location.reload();
                     xadmin.close();
                  }, 1000); 
              }else{
                  layer.msg(res.msg);
                  setTimeout(() => {
                      $('#submit').removeAttr("disabled");
                      $('#submit').removeClass('layui-btn-disabled');
                  }, 1000);
              }
          })
                return false; //阻止表单跳转。如果需要表单跳转，去掉这段即可。
    });

  });

  </script>